<template>
  <div class="app-container">
    <section>
      <div>
        <div
          style="font-size:20px;font-weight: bold;margin-bottom: 20px;text-align: center;display:inline-blok"
        >
          采购订单
          <div style="margin-left:40px;display:inline">
            <el-button size="mini" v-if="from.BillStatus==0" round>草稿</el-button>
            <el-button size="mini" v-if="from.BillStatus==1" round>已审核</el-button>
          </div>
        </div>
      </div>
      <!--工具条-->
      <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
        <el-form
          :inline="true"
          ref="from"
          :model="from"
          label-width="80px"
          class="demo-form-inline"
        >
          <div class="tabel">
            <el-form-item label="订单编号:">
              <span>{{from.OrderNo}}</span>
            </el-form-item>
            <el-form-item label="仓库" prop="BranchId">
              <el-select v-model="from.BranchId" filterable placeholder="请选择仓库">
                <el-option
                  v-for="item in StoreList"
                  :key="item.BranchId"
                  :label="item.BranchName"
                  :value="item.BranchId"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="制单人:">
              <span>{{from.CreaterName}}</span>
            </el-form-item>
            <el-form-item label="制单时间:">
              <span>{{from.CreateDate}}</span>
            </el-form-item>
            <el-form-item label="摘要:">
              <el-input auto-complete="off" v-model="from.Summary" maxlength="12"></el-input>
            </el-form-item>

            <el-form-item label="供应商" prop="SupplierId">
              <el-select v-model="from.SupplierId" filterable placeholder="请选择供应商">
                <el-option
                  v-for="item in SupplierList"
                  :key="item.SupplierId"
                  :label="item.SupplierName"
                  :value="item.SupplierId"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item style="margin-left:400px" v-show="disappeara">
              <el-button type="primary" @click="handleEdit()">新增商品</el-button>
              <el-button
                v-if="from.BillStatus==0"
                type="primary"
                @click="UpdataAndAdd()"
                :loading="UpdataAndAddLoading"
              >保存</el-button>
              <el-button
                v-if="(this.$route.query.POId || this.POId)&&from.BillStatus==0"
                type="success"
                @click="CheckPurchaseOrders()"
              >审核</el-button>
              <el-button v-if="from.BillStatus==1" type="danger" @click="UnCheckPurchaseOrders()">反审</el-button>
            </el-form-item>
          </div>
        </el-form>
      </el-col>
      <el-table :data="List" border height="600" :summary-method="getSummaries" show-summary>
        <el-table-column prop="SKUName" label="商品名称" align="center"></el-table-column>
        <el-table-column prop="SupplierId" label="供应商" align="center"></el-table-column>
        <el-table-column prop="SKUUnitNo" label="单位" align="center"></el-table-column>
        <el-table-column prop="IsGift" label="赠品" align="center">
          <template slot-scope="scope">
            <el-checkbox @change="handlesum(scope.$index,scope.row)" v-model="scope.row.IsGift"></el-checkbox>
          </template>
        </el-table-column>
        <el-table-column prop="Qty" label="订货数量" align="center">
          <template slot-scope="scope">
            <el-input-number
              @change="handlesum(scope.$index,scope.row)"
              v-model="scope.row.Qty"
              size="mini"
              :min="1"
              :step="0.1"
              :precision="2"
            ></el-input-number>
          </template>
        </el-table-column>
        <el-table-column prop="SKUInPrice" label="进价" align="center">
          <template slot-scope="scope">
            <el-input-number
              @change="handlesum(scope.$index,scope.row)"
              v-model="scope.row.SKUInPrice"
              :precision="2"
              :step="0.1"
              :min="0"
              size="mini"
            ></el-input-number>
          </template>
        </el-table-column>
        <el-table-column prop="DiscountRate" label="折扣率" align="center">
          <template slot-scope="scope">
            <el-input-number
              @change="handlesum(scope.$index,scope.row)"
              v-model="scope.row.DiscountRate"
              :precision="2"
              :step="0.1"
              :min="0"
              :max="1"
              size="mini"
            ></el-input-number>
          </template>
        </el-table-column>
        <el-table-column prop="zke" label="折扣额" align="center">
          <template slot-scope="scope">
            <span>{{scope.row.zke.toFixed(2)|numFilter}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="zqje" label="折前金额" align="center">
          <template slot-scope="scope">
            <span>{{scope.row.zqje.toFixed(2)|numFilter}}</span>
          </template>
        </el-table-column>

        <el-table-column prop="zhje" label="折后金额" align="center">
          <template slot-scope="scope">
            <span>{{scope.row.zhje.toFixed(2)|numFilter}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="Remark" label="备注" align="center">
          <template slot-scope="scope">
            <el-input v-model="scope.row.Remark" placeholder="请输入内容" maxlength="12"></el-input>
          </template>
        </el-table-column>
      </el-table>
      <!-- 编辑 -->
      <el-dialog title="商品列表" :visible.sync="editFormVisible">
        <el-form :inline="true">
          <!-- <el-form-item label="商品名">
            <el-input v-model="from.name" auto-complete="off"></el-input>
          </el-form-item>-->
          <el-form-item label="商品">
            <el-input v-model="from.PYCode" auto-complete="off"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button @click="getSkuList()" type="primary">查询</el-button>
            <el-button type="primary" @click.native="addSubmit()">新 增</el-button>
          </el-form-item>
        </el-form>
        <el-table
          :data="skulist"
          ref="multipleTable"
          height="500"
          border
          style="width: 100%; margin-top: 20px"
          tooltip-effect="dark"
          @selection-change="handleSelectionChange"
          :row-key="getRowKeys"
        >
          <el-table-column type="selection" width="55" :reserve-selection="true"></el-table-column>
          <el-table-column prop="ProductId" label="商品ID" align="center"></el-table-column>
          <el-table-column prop="SKUName" label="商品名称" align="center"></el-table-column>
          <el-table-column prop="SKUUnitNo" label="单位" align="center"></el-table-column>
          <el-table-column prop="SKUInPrice" sortable label="进价" align="center"></el-table-column>
        </el-table>
        <div style="text-align:center;margin-top:10px;">
          <!-- <el-button @click="editFormVisible = false">取 消</el-button> -->
          <!-- <el-button type="primary" @click.native="addSubmit()">新 增</el-button> -->
        </div>
        <span slot="footer"></span>
        <div>
          <el-pagination
            background
            layout=" prev, pager, next, jumper"
            @current-change="handleCurrentChange"
            :page-size="pageSize"
            :total="total"
            style="float:right;margin-top: 10px;"
          ></el-pagination>
        </div>
      </el-dialog>
    </section>
  </div>
</template>

<script>
import {
  SKUList,
  GetPurchaseOrdersDetailList,
  GetPurchaseOrdersDetail,
  AddPurchaseOrders,
  GetPurchaseOrdersAdd,
  PurchaseGetSupplierList,
  UpdateurchaseOrders,
  CheckPurchaseOrders,
  UnCheckPurchaseOrders
} from "@/api/api";
import Config from "../../api/config";
export default {
  data() {
    return {
      skulist: [],
      editFormVisible: false,
      page: 1,
      pageSize: 100,
      total: 0,
      POId: "",
      from: {
        Qty: "",
        OrderNo: "",
        Creater: "",
        Creater2: "",
        CreateDate: "",
        SupplierName: "",
        Summary: "",
        BillStatus: "",
        SupplierId: "",
        BranchId: 15
      },
      tempList: [
        {
          ProductId: "",
          IsGift: "0",
          Unit: "",
          Qty: "",
          Price: "",
          DiscountRate: "",
          Remark: ""
        }
      ],
      UpdataAndAddLoading: false,
      SupplierList: [],
      Id: "",
      List: [],
      StoreList: [
        {
          BranchName: "总仓",
          BranchId: 15
        }
      ],
      hide: true, //草稿
      hides: false, //已审核
      disappear: true, //保存
      disappears: false, //审核
      disappeard: false, //反审
      disappeara: true //增加
    };
  },
  created() {
    this.POId = this.$route.query.POId ? this.$route.query.POId : "";
    this.getPurchaseOrders();
    this.PurchaseGetSupplierList();
  },

  filters: {
    numFilter(value) {
      // 截取当前数据到小数点后两位
      let realVal = parseFloat(value).toFixed(2);
      return realVal;
    }
  },
  methods: {
    handleAllSum() {
      var self = this;
      this.List.forEach(function(row, index) {
        console.log("输出row", row);
        console.log("index", index);
        self.handlesum(index, row);
      });
    },

    handlesum: function(index, row) {
      if (!row) return;
      if (row.IsGift == 1) {
        row.zqje = 0;
      } else {
        row.zqje = row.Qty * row.SKUInPrice * 1;
      }

      if (row.IsGift == 1) {
        row.zke = 0;
      } else {
        row.zke =
          row.SKUInPrice * row.Qty -
          row.SKUInPrice * row.DiscountRate * row.Qty;
      }

      if (row.IsGift == 1) {
        row.zhje = 0;
      } else {
        row.zhje = row.SKUInPrice * row.DiscountRate * row.Qty;
      }
      this.List[index] = row;
      console.log(this.List);
      if (row.Qty <= 0) {
        this.hide = false;
        return;
      }
    },
    //显示新增
    handleEdit: function() {
      this.editFormVisible = true;
      console.log(this.List);
      this.getSkuList();
    },
    //选择商品添加
    addSubmit() {
      // var vdata = this.jsonspr;
      // // debugger
      // for (var j in vdata) {
      //   // vdata[j].Qty = 1;
      //   for (var i in this.List) {
      //     if (vdata[j].ProductId == this.List[i].ProductId) {
      //       vdata[j] = this.List[i];
      //     }
      //   }
      // }
      let new_result = this.unique(this.List.concat(this.jsonspr));
      console.log('///////////////////////////////////////////////////////////////////');
      console.log(new_result);
      console.log('///////////////////////////////////////////////////////////////////');
      this.List = new_result;
      this.handleAllSum();
      this.editFormVisible = false;
    },
    /**
     * @Author: 王灿
     * @Descripttion: 合并数组去重
     * @Date: 2019-12-19 16:04:28
     */
    unique(arr) {
      const res = new Map();
      return arr.filter((arr) => !res.has(arr.ProductId) && res.set(arr.ProductId, 1))
    },
    getRowKeys(row) {
      return row.ProductId;
    },
    //选择器
    handleSelectionChange(val) {
      console.log(val);
      this.jsonspr = val;
      this.handleAllSum();
    },
    getPurchaseOrders() {
      this.POId = this.$route.query.POId ? this.$route.query.POId : "";
      var huo = this.$route.query.huo;
      if (this.POId !== "") {
        this.GetPurchaseOrdersDetail();
      } else if (huo != null) {
        this.GetPurchaseOrdersAdd();
        this.geLocal();
      } else {
        this.GetPurchaseOrdersAdd();
        return;
      }
    },

    geLocal() {
      var data1 = JSON.parse(localStorage.getItem("huo"));
      console.log("输出缓存数组", data1);
      this.List = data1;
      var list = this.List;
      this.handleAllSum();
    },

    //有值的时候为修改，无值的时候添加
    UpdataAndAdd() {
      if (this.POId) {
        this.UpdateurchaseOrders();
      } else {
        this.AddPurchaseOrders();
        return;
      }
    },

    //获取商品以及表头
    GetPurchaseOrdersDetail() {
      var self = this;

      var para = {
        SessionId: JSON.parse(localStorage.getItem("userinfo")).SessionId,
        POId: this.$route.query.POId ? this.$route.query.POId : this.POId,
        Page: this.page,
        PageSize: this.pageSize
      };
      GetPurchaseOrdersDetail(para).then(res => {
        if (res.data.Status != 1) {
          this.$message({
            message: res.data.Description,
            type: "error"
          });
          return;
        } else {
          var vdata = JSON.parse(Base64.decode(res.data.Data));
          console.log("获取采购订单表体列表");
          console.log(vdata);
          self.List = vdata.DataList;
          self.List.forEach(el => {
            console.log("..............", el.IsGift);
            if (el.IsGift == 0) {
              el.IsGift = false;
            } else if (el.IsGift == 1) {
              el.IsGift = true;
            }
          });
          if (self.List.length === 0) {
            this.$message({
              message: "该订单已被删除",
              type: "error",
              duration: 1000,
              onClose: () => {
                self.$store
                  .dispatch("delView", self.$route)
                  .then(({ visitedViews }) => {
                    console.log(self.$router)
                     visitedViews.splice(
                      visitedViews.findIndex(item => item.path === self.$route.path,1));
                    self.$store.dispatch('updateVisitedView', visitedViews)
                    self.$router.push("/Purchase/Purchase")
                  });
              }
            });
          } else {
            this.from.OrderNo = self.List[0].OrderNo;
            this.from.CreateDate = self.List[0].CreateDate.substr(0, 10);
            this.from.Creater = self.List[0].Creater;
            this.from.Summary = self.List[0].Summary;
            this.from.SupplierName = self.List[0].SupplierName;
            this.from.BillStatus = self.List[0].BillStatus;
            this.from.SupplierId = self.List[0].SupplierId;
            this.from.CreaterName = self.List[0].CreaterName;
            this.handleAllSum();
          }
        }
      });
    },

    //审核采购订单
    CheckPurchaseOrders() {
      var self = this;
      self.tempList = [];
      for (var item in self.List) {
        var a = {
          ProductId: self.List[item].ProductId,
          IsGift: self.List[item].IsGift == "1" ? 1 : 0,
          Unit: self.List[item].SKUUnitNo,
          Qty: self.List[item].Qty,
          Price: self.List[item].SKUInPrice,
          DiscountRate: self.List[item].DiscountRate,
          Remark: self.List[item].Remark
        };
        self.tempList.push(a);
      }
      if (self.tempList[item].Qty <= 0) {
        this.$message({
          message: "请检查订货数量",
          type: "error"
        });
        return;
      }
      var para = {
        SessionId: JSON.parse(localStorage.getItem("userinfo")).SessionId,
        Creater: this.from.Creater,
        POID: this.$route.query.POId ? this.$route.query.POId : this.POId,
        SupplierId: this.from.SupplierId,
        Summary: this.from.Summary,
        BranchId: this.from.BranchId,
        tempList: self.tempList
      };
      UpdateurchaseOrders(para).then(res => {
        if (res.data.Status != 1 || res.data.Status == 11) {
          this.$message({
            message: res.data.Description,
            type: "error"
          });
          return;
        } else {
          var para = {
            SessionId: JSON.parse(localStorage.getItem("userinfo")).SessionId,
            POID: this.$route.query.POId ? this.$route.query.POId : this.POId
          };
          CheckPurchaseOrders(para).then(res => {
            if (res.data.Status != 1) {
              this.$message({
                message: res.data.Description,
                type: "error"
              });
              return;
            } else {
              this.$message({
                message: res.data.Description,
                type: "success"
              });

              this.GetPurchaseOrdersDetail();
            }
          });
        }
      });
    },

    //反审
    UnCheckPurchaseOrders() {
      var self = this;
      var para = {
        SessionId: JSON.parse(localStorage.getItem("userinfo")).SessionId,
        POID: this.$route.query.POId ? this.$route.query.POId : this.POId
      };
      UnCheckPurchaseOrders(para).then(res => {
        if (res.data.Status != 1) {
          this.$message({
            message: res.data.Description,
            type: "error"
          });
          return;
        } else {
          this.$message({
            message: res.data.Description,
            type: "success"
          });
          this.GetPurchaseOrdersDetail();
        }
      });
    },

    //获取采购表头(新增时)
    GetPurchaseOrdersAdd() {
      var self = this;
      var para = {
        SessionId: JSON.parse(localStorage.getItem("userinfo")).SessionId,
        Exter: "CG"
      };
      GetPurchaseOrdersAdd(para).then(res => {
        if (res.data.Status != 1) {
          this.$message({
            message: res.data.Description,
            type: "error"
          });
          return;
        } else {
          var vdata = JSON.parse(Base64.decode(res.data.Data));
          console.log("获取采购表头", vdata);
          this.from.OrderNo = vdata.OrderNo;
          this.from.CreateDate = vdata.dateTime.substr(0, 10);
          this.from.CreaterName = vdata.CreaterName;
          this.from.Creater2 = vdata.Creater;
        }
      })
    },

    // toggleSelection(rows) {
    //   if (rows) {
    //     rows.forEach(row => {
    //       this.$refs.multipleTable.toggleRowSelection(row);
    //     });
    //   } else {
    //     this.$refs.multipleTable.clearSelection();
    //   }
    // },
    // toggleSelection(row) {
    //   console.log("执行选择", row);

    //   this.$refs.multipleTable.toggleRowSelection(row);
    // },
    //新增采购列表
    AddPurchaseOrders() {
      this.UpdataAndAddLoading = true;
      var self = this;
      self.tempList = [];
      for (var item in self.List) {
        var a = {
          ProductId: self.List[item].ProductId,
          IsGift: self.List[item].IsGift == "1" ? 1 : 0,
          Unit: self.List[item].SKUUnitNo,
          Qty: self.List[item].Qty,
          Price: self.List[item].SKUInPrice,
          DiscountRate: self.List[item].DiscountRate,
          Remark: self.List[item].Remark
        };
        self.tempList.push(a);
      }
      console.log("阿加厚的", self.tempList);

      if (!this.from.SupplierId) {
        this.$message({
          message: "供应商不能为空",
          type: "error"
        });
        this.UpdataAndAddLoading = false;
        return;
      }

      if (self.tempList.length == 0) {
        this.$message({
          message: "商品不能为空",
          type: "error"
        });
        this.UpdataAndAddLoading = false;
        return;
      }
      var para = {
        SessionId: JSON.parse(localStorage.getItem("userinfo")).SessionId,
        Creater: this.from.Creater2,
        SupplierId: this.from.SupplierId,
        Summary: this.from.Summary,
        BranchId: this.from.BranchId,
        tempList: self.tempList
      };

      // for(var item in self.tempList){

      //    if (self.tempList[item].Qty<=0) {
      //   this.$message({
      //     message: "请检查订货数量",
      //     type: "error"
      //   });
      //   this.hide=true;
      //   return;
      //  }
      // }

      AddPurchaseOrders(para).then(res => {
        if (res.data.Status != 1) {
          this.$message({
            message: res.data.Description,
            type: "error"
          });
          this.UpdataAndAddLoading = false;
          return;
        } else {
          this.$message({
            message: res.data.Description,
            type: "success",
            duration: 1000,
            onClose: () => {
              self.UpdataAndAddLoading = false;
              self.onGetPurchaseOrdersDetailList();
            }
          });
        }
      });
    },

    // 根据OrderNo获取采购详细信息
    onGetPurchaseOrdersDetailList() {
      const self = this;
      let para = {
        SessionId: JSON.parse(localStorage.getItem("userinfo")).SessionId,
        OrderNo: this.from.OrderNo,
        EndDate: undefined,
        OderNo: undefined,
        OrderStatus: -1,
        Page: 1,
        PageSize: 100,
        PaymentStatus: -1,
        StartDate: undefined,
        Summary: undefined,
        SupplierId: undefined
      };
      GetPurchaseOrdersDetailList(para).then(res => {
        if (res.data.Status != 1) {
          this.$message({
            message: res.data.Description,
            type: "error"
          });
          return;
        } else {
          let vdata = JSON.parse(Base64.decode(res.data.Data));
          self.POId = vdata.DataList[0].POId;
          self.GetPurchaseOrdersDetail();
        }
      });
    },

    add() {
      this.$router.push({
        path: "/Purchase/Purchase"
      });
    },

    //修改采购订单
    UpdateurchaseOrders() {
      var self = this;
      self.tempList = [];
      for (var item in self.List) {
        var a = {
          ProductId: self.List[item].ProductId,
          IsGift: self.List[item].IsGift == "1" ? 1 : 0,
          Unit: self.List[item].SKUUnitNo,
          Qty: self.List[item].Qty,
          Price: self.List[item].SKUInPrice,
          DiscountRate: self.List[item].DiscountRate,
          Remark: self.List[item].Remark
        };
        self.tempList.push(a);
      }
      if (self.tempList[item].Qty <= 0) {
        this.$message({
          message: "请检查订货数量",
          type: "error"
        });
        return;
      }
      var para = {
        SessionId: JSON.parse(localStorage.getItem("userinfo")).SessionId,
        Creater: this.from.Creater,
        SupplierId: this.from.SupplierId,
        Summary: this.from.Summary,
        BranchId: this.from.BranchId,
        POID: this.$route.query.POId ? this.$route.query.POId : this.POId,
        tempList: self.tempList
      };
      UpdateurchaseOrders(para).then(res => {
        if (res.data.Status != 1 || res.data.Status == 11) {
          this.$message({
            message: res.data.Description,
            type: "error"
          });
          return;
        } else {
          this.$message({
            message: res.data.Description,
            type: "success"
          });

          var vdata = JSON.parse(JSON.stringify(Base64.decode(res.data.Data)));
          console.log("获取商品列表", vdata);
          var list = vdata.DataList;
          self.skulist = list;
        }
      });
    },

    //获取供应商列表
    PurchaseGetSupplierList() {
      var self = this;
      var para = {
        SessionId: JSON.parse(localStorage.getItem("userinfo")).SessionId,
        Page: this.page,
        PageSize: 20000
      };
      PurchaseGetSupplierList(para).then(res => {
        if (res.data.Status != 1) {
          this.$message({
            message: res.data.Description,
            type: "error"
          });
          return;
        } else {
          var vdata = JSON.parse(Base64.decode(res.data.Data));
          console.log("获取供应商列表", vdata);
          var list = vdata.DataList;
          self.SupplierList = list;
        }
      });
    },

    first1(rows) {
      this.$nextTick(() => {
        rows.forEach(row => {
          this.$refs.multipleTable.toggleRowSelection(row, true);
        });
      });
    },
    //获取商品列表
    getSkuList() {
      var self = this;
      console.log("输出选择项目", this.vdata);
      var para = {
        sessionid: JSON.parse(localStorage.getItem("userinfo")).SessionId,
        page: this.page,
        pagesize: 100,
        // name: this.from.name,a
        PYCode: this.from.PYCode
      };
      var str = this.from.PYCode;
      console.log(str);
      if (/^[\u4e00-\u9fa5]+$/i.test(str)) {
        para.name = str;
        para.PYCode = " ";
      } else {
        para.name = " ";
      }
      //传入的值
      console.log("1号庄");
      console.log(para);
      SKUList(para).then(res => {
        if (res.data.Status != 1) {
          this.$message({
            message: res.data.Description,
            type: "error"
          });
          return;
        } else {
          var vdata = JSON.parse(Base64.decode(res.data.Data));
          console.log("获取商品列表", vdata);
          var list = vdata.DataList;
          self.skulist = list;
          this.total = vdata.TotalCount;
          // this.wids = res.data.result.wids                 //点击详情接口返回的 table里被选中的行的wids
          let a = []; //    res.data.result.wids.split(',')          //分割成数组
          self.List.forEach(res => {
            //把表格里所有的id加入到b里
            a.push(res.ProductId.toString());
          });
          console.log("1", a);
          let b = [];
          self.skulist.forEach(res => {
            //把表格里所有的id加入到b里
            b.push(res.ProductId.toString());
          });
          console.log("0", b);
          // console.log(typeof(b[0]))
          for (let c = 0; c < b.length; c++) {
            //对b循环  如果b里面有a（a是被选中的行） 则把索引代入到first函数里 让这些行的复选框选中
            // console.log(b[c])
            // console.log(a.indexOf(b[c]))
            if (b.indexOf(a[c]) >= 0) {
              console.log(a.indexOf(b[c]));
              self.first1([self.skulist[b.indexOf(a[c])]]);
            }
          }
        }
      });
    },

    //求和
    getSummaries(param) {
      const { columns, data } = param;
      console.log("param", param);
      //console.log('data', data)
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = "合计";
          return;
        }
        if (index == 7) {
          sums[index] = 0;
          for (var item in data) {
            var row = data[item];
            if (row.IsGift == 1) {
              row.zke = 0;
            } else {
              row.zke =
                row.SKUInPrice * row.Qty -
                row.SKUInPrice * row.DiscountRate * row.Qty;
            }
            sums[index] += data[item].zke;
          }
          sums[index] = sums[index].toFixed(2);
        }
        if (index == 8) {
          sums[index] = 0;
          for (var item in data) {
            sums[index] += data[item].zqje;
          }
          sums[index] = sums[index].toFixed(2);
        }
        if (index == 9) {
          sums[index] = 0;
          for (var item in data) {
            sums[index] += data[item].zhje;
          }
          sums[index] = sums[index].toFixed(2);
        }
        // if (index !== 11) {
        //   return;
        // }
        // const values = data.map(item => {
        //   return Number(item[column.property]);
        // });
        // if (!values.every(value => isNaN(value))) {
        //   sums[index] = values.reduce((prev, curr) => {
        //     const value = Number(curr);
        //     if (!isNaN(value)) {
        //       return prev + curr;
        //     } else {
        //       return prev;
        //     }
        //   }, 0);
        //   sums[index] += "元";
        // }
      });

      return sums;
    },

    //翻页
    handleCurrentChange(val) {
      this.page = val;
      this.getSkuList();
    }
  }
};
</script>
<style scoped>
.tabel {
  display: inline-block;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  width: 90%;
}
.tabel .el-form-item {
  width: 32%;
  /* letter-spacing:8px; */
}
.tabel .el-button {
  padding: 0 20px;
  height: 30px;
}
.el-form-item--medium .el-form-item__content,
.el-form-item--medium .el-form-item__label {
  color: black;
}
span {
  color: black;
}
.class /deep/ .a input::-webkit-outer-spin-button,
.class /deep/ .a input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}
.class /deep/ .a input[type="number"] {
  -moz-appearance: textfield;
}
</style>